package fr.perso.spring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import fr.perso.spring.jmx.RegisterService;

public class MultipleBean implements InitializingBean{
	
	boolean actifA= false;
	
	boolean actifB = false;
	
	SimpleBeanA beanA;
	
	SimpleBeanB beanB;
	
	RegisterService service;
	
	
	private final Logger log = LoggerFactory.getLogger(MultipleBean.class);
	
	public String listeValeur() throws Exception {
		log.warn("Appel a listeValeur");
		
		StringBuilder s = new StringBuilder();
		
		if(actifA) {
			s.append("\n beanA:").append(beanA);
		}
		if(actifB) {
			s.append("\n beanB:").append(beanB);
		}
		s.append("\n jmxBean( ").append("Age:").append(service.getJmxBean().getAge()).append("  Name:").append(service.getJmxBean().getName()).append(")");
		log.warn("toString: {}", s.toString());
		log.warn("FIN Appel a listeValeur");
		return s.toString();
	}


	public boolean isActifA() {
		return actifA;
	}


	public void setActifA(boolean actifA) {
		this.actifA = actifA;
	}


	public boolean isActifB() {
		return actifB;
	}


	public void setActifB(boolean actifB) {
		this.actifB = actifB;
	}


	public SimpleBeanA getBeanA() {
		return beanA;
	}


	public void setBeanA(SimpleBeanA beanA) {
		this.beanA = beanA;
	}


	public SimpleBeanB getBeanB() {
		return beanB;
	}


	public void setBeanB(SimpleBeanB beanB) {
		this.beanB = beanB;
	}


	public void afterPropertiesSet() throws Exception {
		log.warn("INIT------- actifA: {}   actifB: {}", new Object[] {actifA, actifB});
		
	}


	public void setService(RegisterService service) {
		this.service = service;
	}
	
	
	
	
	
	
	

}
